using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class MedicineInterveneViewMap : EntityTypeConfiguration<MedicineInterveneView>
    {
        public MedicineInterveneViewMap()
        {
            // Primary Key
            this.HasKey(t => new { t.patient_id, t.name, t.gender, t.id_card, t.medicine_name, t.medical_plan_id, t.IsMedicalPlan });

            // Properties
            this.Property(t => t.patient_id)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.name)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.gender)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.id_card)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.medicine_name)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.usage)
                .HasMaxLength(200);

            this.Property(t => t.dosage)
                .HasMaxLength(200);

            this.Property(t => t.note)
                .HasMaxLength(200);

            this.Property(t => t.medical_plan_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.IsMedicalPlan)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("MedicineInterveneView");
            this.Property(t => t.patient_id).HasColumnName("patient_id");
            this.Property(t => t.name).HasColumnName("name");
            this.Property(t => t.gender).HasColumnName("gender");
            this.Property(t => t.id_card).HasColumnName("id_card");
            this.Property(t => t.medicine_id).HasColumnName("medicine_id");
            this.Property(t => t.medicine_name).HasColumnName("medicine_name");
            this.Property(t => t.drug_type_id).HasColumnName("drug_type_id");
            this.Property(t => t.frequency).HasColumnName("frequency");
            this.Property(t => t.usage).HasColumnName("usage");
            this.Property(t => t.dosage).HasColumnName("dosage");
            this.Property(t => t.note).HasColumnName("note");
            this.Property(t => t.medical_plan_id).HasColumnName("medical_plan_id");
            this.Property(t => t.start_time).HasColumnName("start_time");
            this.Property(t => t.end_time).HasColumnName("end_time");
            this.Property(t => t.IsMedicalPlan).HasColumnName("IsMedicalPlan");
            this.Property(t => t.intervention_plan_id).HasColumnName("intervention_plan_id");
        }
    }
}
